<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>协议配置编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <link rel="stylesheet" href="/web/res/wangEditor/wangEditor.css">

    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
</head>

<body style="background-color: white;">
<div class="layui-fluid" id="orderEdit">
    <form class="layui-form layui-form-pane" id="formsubmit" style="width: 800px;margin:20px"
          action="/after/setup/save">

        <input type="hidden" id="id" name="id" value="${(byId.id?c)!''}">

        <div class="layui-form-item">
            <label class="layui-form-label">用户协议</label>
            <div class="layui-input-block">
                <div id="editor1" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">隐私协议</label>
            <div class="layui-input-block">
                <div id="editor2" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">平台行为规范</label>
            <div class="layui-input-block">
                <div id="editor18" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">直播开通服务协议</label>
            <div class="layui-input-block">
                <div id="editor19" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">直播管理规则</label>
            <div class="layui-input-block">
                <div id="editor20" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">房主协议</label>
            <div class="layui-input-block">
                <div id="editor3" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">充值协议</label>
            <div class="layui-input-block">
                <div id="editor4" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">兑换协议</label>
            <div class="layui-input-block">
                <div id="editor5" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">主播协议</label>
            <div class="layui-input-block">
                <div id="editor6" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">等级说明</label>
            <div class="layui-input-block">
                <div id="editor7" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">实名认证说明</label>
            <div class="layui-input-block">
                <div id="editor8" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">视频认证说明</label>
            <div class="layui-input-block">
                <div id="editor9" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">直播公告</label>
            <div class="layui-input-block">
                <div id="editor10" style="width: 200%">
                </div>
            </div>
        </div>
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">粉丝团说明</label>
            <div class="layui-input-block">
                <div id="editor11" style="width: 200%">
                </div>
            </div>
        </div> -->

        <div class="layui-form-item">
            <label class="layui-form-label">邀请规则说明</label>
            <div class="layui-input-block">
                <div id="editor12" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">收费设置说明</label>
            <div class="layui-input-block">
                <div id="editor14" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系方式</label>
            <div class="layui-input-block">
                <div id="editor13" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">认证问题</label>
            <div class="layui-input-block">
                <div id="editor15" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">邀请规则</label>
            <div class="layui-input-block">
                <div id="editor16" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">如何提升魅力</label>
            <div class="layui-input-block">
                <div id="editor17" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">文明公约</label>
            <div class="layui-input-block">
                <div id="editor21" style="width: 200%">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="save">&emsp;确认&emsp;
                </button>
                <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="xadmin.close()">
                    &emsp;返回&emsp;
                </button>
            </div>
        </div>

    </form>
</div>
<script type="text/javascript" src="/web/res/wangEditor/wangEditor.js"></script>
<script>
    layui.use(['form', 'upload'], function () {
        let $ = layui.$;
        var form = layui.form;
        var upload = layui.upload;
        form.render();

        $.fn.extend({
            serializeObject: function () {
                var obj = {}; //声明一个对象
                $.each(this.serializeArray(), function (index, field) {
                    obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
                })
                return obj;
            }
        });

        //  单文件上传
        upload.render({
            elem: '#test5'
            , url: '/after/gift/uploadLiveImg'
            , accept: 'file'
            //, acceptMime: '.xlsx,.xls,.csv'//筛选指定后缀文件
            , choose: function (obj) {
                obj.preview(function (index, file, result) {
                    $('#specialeffect').val(file.name)
                });
            }
            , before: function (obj) {
                layer.load();
            }
            , done: function (res) {
                console.log(res);
                $("#specialeffects").val(res.data.name);
                layer.closeAll('loading');
                layer.msg('上传成功');
            }
        });



        $(function () {
            $('#saudiw img').on('click', function () {
                layer.photos({
                    photos: '#saudiw',
                    shadeClose: false,
                    closeBtn: 2,
                    anim: 0
                });
            })
        });
        form.on('submit(' + $("button[lay-submit]:eq(0)").attr("lay-filter") + ')', function (data) {
            if($("#giftid").val()===''){
                layer.msg("请选择礼物", {icon: 2, time: 1000}, function () {});
                return false;
            }


            layer.confirm('确认要保存吗？', function (index) {
                var str1=editor1.txt.html();
                var str2=editor2.txt.html();
                var str3=editor3.txt.html();
                var str4=editor4.txt.html();
                var str5=editor5.txt.html();
                var str6=editor6.txt.html();
                var str7=editor7.txt.html();
                var str8=editor8.txt.html();
                var str9=editor9.txt.html();
                var str10 = editor10.txt.html();
                var str11 = editor11.txt.html();
                var str12 = editor12.txt.html();
                var str13 = editor13.txt.html();
                var str14 = editor14.txt.html();
                var str15 = editor15.txt.html();
                var str16 = editor16.txt.html();
                var str17 = editor17.txt.html();
                var str18 = editor18.txt.html();
                var str19 = editor19.txt.html();
                var str20 = editor20.txt.html();
                var str21 = editor21.txt.html();


                ajaxPost(layui.$, $("#formsubmit").attr("action"), {
                    "useragreement":str1,
                    "privacyprotocol":str2,
                    "houseagreement":str3,
                    "rechargeagreement":str4,
                    "exchangeagreement":str5,
                    "anchorprotocol":str6,
                    "dengjishuoming":str7,
                    "shimingrenzheng":str8,
                    "shipinrenzheng":str9,
                    "huodongguize":str10,
                    "invitationrulesL":str12,
                    "fensituanshuoming":str11,
                    "lianxi":str13,
                    "priceSetExplain":str14,
                    "authagreement":str15,
                    "invitegreement":str16,
                    "charmgreement":str17,
                    "platformConductStandard":str18,
                    "liveServiceAgreement":str19,
                    "liveManagementStandard":str20,
                    "wmAgreement":str21
                }, function (data) {
                    if (data.code == 0) {

                        layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                            //xadmin.father_reload();
                            location.reload();
                        });
                    } else {
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, time: 1000}, function () {

                        });
                    }
                });
            });
        });

    });

    var E = window.wangEditor;
    var editor1 = new E('#editor1');
    var editor2 = new E('#editor2');
    var editor3 = new E('#editor3');
    var editor4 = new E('#editor4');
    var editor5 = new E('#editor5');
    var editor6 = new E('#editor6');
    var editor7 = new E('#editor7');
    var editor8 = new E('#editor8');
    var editor9 = new E('#editor9');
    var editor10 = new E('#editor10');
    var editor11 = new E('#editor11');
    var editor12 = new E('#editor12');
    var editor13 = new E('#editor13');
    var editor14 = new E('#editor14');
    var editor15 = new E('#editor15');
    var editor16 = new E('#editor16');
    var editor17 = new E('#editor17');
    var editor18 = new E('#editor18');
    var editor19 = new E('#editor19');
    var editor20 = new E('#editor20');
    var editor20 = new E('#editor20');
    var editor21 = new E('#editor21');
    editor13.customConfig.uploadImgServer = '/after/setup/setupUpload';
    editor13.customConfig.uploadFileName = 'myFileName';
    editor13.customConfig.uploadImgHooks = {
        before: function(xhr, editor, files) {
        },
        success: function(xhr, editor, result) {
            var num=$("#graphics").val();
            $("#graphics").val("");
            $("#graphics").val(parseInt(num)+1);
            var url=$("#imageUrl").val();
            console.log(url);
            console.log(url=='');
            if(url==''){
                $("#imageUrl").val(result.data[0]);
            }else{
                $("#imageUrl").val(url+","+result.data[0]);
            }
            console.log("上传成功");
        },
        fail: function(xhr, editor, result) {

            console.log("上传失败,原因是" + result);
        },
        error: function(xhr, editor) {
            console.log("上传出错");
        },
        timeout: function(xhr, editor) {
            console.log("上传超时");
        }
    };
    editor1.create();
    editor2.create();
    editor3.create();
    editor4.create();
    editor5.create();
    editor6.create();
    editor7.create();
    editor8.create();
    editor9.create();
    editor10.create();
    editor11.create();
    editor12.create();
    editor13.create();
    editor14.create();
    editor15.create();
    editor16.create();
    editor17.create();
    editor18.create();
    editor19.create();
    editor20.create();
    editor21.create();
    editor1.txt.html('${byId.useragreement}');
    editor2.txt.html('${byId.privacyprotocol}');
    editor3.txt.html('${byId.houseagreement}');
    editor4.txt.html('${byId.rechargeagreement}');
    editor5.txt.html('${byId.exchangeagreement}');
    editor6.txt.html('${byId.anchorprotocol}');
    editor7.txt.html('${byId.dengjishuoming}');
    editor8.txt.html('${byId.shimingrenzheng}');
    editor9.txt.html('${byId.shipinrenzheng}');
    editor10.txt.html('${(byId.huodongguize)!''}');
    editor11.txt.html('${(byId.fensituanshuoming)!''}');
    editor12.txt.html('${(byId.invitationrulesL)!''}');
    editor13.txt.html('${(byId.lianxi)!''}');
    editor14.txt.html('${byId.priceSetExplain}');
    editor15.txt.html('${byId.authagreement}');
    editor16.txt.html('${byId.invitegreement}');
    editor17.txt.html('${byId.charmgreement}');
    editor18.txt.html('${byId.platformConductStandard}');
    editor19.txt.html('${byId.liveServiceAgreement}');
    editor20.txt.html('${byId.liveManagementStandard}');
    editor21.txt.html('${byId.wmAgreement}');
</script>
</body>

</html>